//
//  yxpViewController.m
//  TestProject
//
//  Created by 杨小平 on 14-8-16.
//  Copyright (c) 2014年 yangxiaoping. All rights reserved.
//

#import "yxpVC.h"
#import "Header.h"

@interface yxpVC ()
{
    NSDictionary *_dictionary;
}


@end

@implementation yxpVC

- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.title=@"TestProject";
    self.view.backgroundColor=[UIColor whiteColor];
    //设定push返回按钮
    UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithTitle:@"主页" style:UIBarButtonItemStyleBordered target:nil action:nil];
    [self.navigationItem setBackBarButtonItem:backItem];
    
    _dictionary=[[NSDictionary alloc] initWithObjectsAndKeys:@"GCD多线程",@"yxpGCDVC",
                                                             @"普通多线程",@"yxpOperationVC",
                                                             @"JSON数据请求",@"yxpJsonRequest",
                                                             @"系统自带两种指示器",@"yxpShowHUD",
                                                             @"MBProgressHUD指示器",@"yxpMBHUD",
                                                             @"摇一摇",@"yxpShakeVC",
                                                             @"分组表格",@"yxpGroupTBVC",
                                                             @"AFNetworking的使用",@"yxpAFNetWorking",
                                                             @"自定义push-pop跳转方法",@"yxpPushPopAnimation",
                                                             @"系统方法读取照片库的图片",@"yxpPickerImage",
                                                             @"仿美团下拉列表",@"yxpPulldownVC",
                                                             @"一种新的通知栏",@"yxpGCDNotification",
                                                             @"UITextField文本框详细使用",@"yxpTextField",
                                                             @"系统字体选择",@"yxpFontSelectionVC",
                                                             @"颜色RGB和16进制值",@"yxpColorSelectionVC",
                                                                nil];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    return _dictionary.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *acell = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:acell];
    if (!cell) {
        cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:acell];
    }
    cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
    cell.textLabel.text=[_dictionary.allValues objectAtIndex:indexPath.row];
    cell.detailTextLabel.text=[_dictionary.allKeys objectAtIndex:indexPath.row];
    
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *className=[_dictionary.allKeys objectAtIndex:indexPath.row];
    
    UIViewController *subViewController = [[NSClassFromString(className) alloc] init];
    subViewController.title=[_dictionary.allValues objectAtIndex:indexPath.row];
    
    [self.navigationController pushViewController:subViewController animated:YES];
}

@end
